package com.hyd.tweet;

import com.google.apphosting.api.ApiProxy;
import com.hyd.tweet.user.User;

/**
 * (description)
 *
 * @author yiding.he
 */
public class Application {

    private static String publicNotification =
            "抱歉，可能由于程序存在的缺陷，导致 GAE 每日免费限额被用光。所以暂时停止服务，这两天优化一下。";

    public static String getAppId() {
        String appId = ApiProxy.getCurrentEnvironment().getAppId();
        if (appId.startsWith("s~")) {
            appId = appId.substring(2);
        }
        return appId;
    }

    public static String getAdministrator() {
        return System.getProperty("administrator");
    }

    public static String getAppChatDomain() {
        return getAppId() + ".appspotchat.com";
    }

    public static boolean isAdmin(User user) {
        return user != null && user.getAccount().equals(getAdministrator());
    }

    public static String getEnabled() {
        return System.getProperty("enabled");
    }

    public static String getPublicNotification() {
        return publicNotification;
    }
}
